package ar.uba.fi.RSACryptoFiuba.model.keygeneration;

import ar.uba.fi.RSACryptoFiuba.model.RSAAlgorithm;
import ar.uba.fi.RSACryptoFiuba.model.RSAAlgorithmStrategy;
import ar.uba.fi.RSACryptoFiuba.model.RSAMessage;
import ar.uba.fi.RSACryptoFiuba.model.RSAStep;


public class RSAKeyGenerationAlgorithm extends RSAAlgorithm{
		
	public RSAKeyGenerationAlgorithm(RSAAlgorithmStrategy strategy, RSAMessage message){
		super(strategy, message);
	}

	@Override
	public void init() {
		RSAStep generatePStep = new GeneratePStep();
		RSAStep generateQStep = new GenerateQStep();
		RSAStep calculateNStep = new CalculateNStep();
		RSAStep calculatePhiStep = new CalculatePhiStep();
		RSAStep calculateDStep = new CalculateDStep();
		RSAStep calculateEStep = new CalculateEStep();
		RSAStep resultsStep = new VoidStep();
			
		generatePStep.setNext(generateQStep);
		generateQStep.setNext(calculateNStep);
		calculateNStep.setNext(calculatePhiStep);
		calculatePhiStep.setNext(calculateDStep);
		calculateDStep.setNext(calculateEStep);
		calculateEStep.setNext(resultsStep);
		
		resultsStep.setPrevious(calculateEStep);
		calculateEStep.setPrevious(calculateDStep);
		calculateDStep.setPrevious(calculatePhiStep);
		calculatePhiStep.setPrevious(calculateNStep);
		calculateNStep.setPrevious(generateQStep);
		generateQStep.setPrevious(generatePStep);
			
		this.setCurrentStep(generatePStep);
	}		

}
